// by Xeno
private ["_isadmin", "_display", "_ctrl", "_units", "_index"];
if (!X_Client) exitWith {};

disableSerialization;

_isadmin = player getVariable "d_p_isadmin";
if (isNil "_isadmin") then {_isadmin = false};

if (!_isadmin) exitWith {};

d_phd_invulnerable = true;

createDialog "XD_AdminDialog";
_display = uiNameSpace getVariable "D_ADMIN_DLG";

_ctrl = _display displayCtrl 1001;

_units = if (isMultiplayer) then {playableUnits} else {switchableUnits};
lbClear _ctrl;
{
	if (!isNull _x) then {
		_index = _ctrl lbAdd (name _x);
		_ctrl lbSetData [_index, str(_x)];
	};
} forEach _units;

_ctrl lbSetCurSel 0;
//onMapSingleClick = "hint 'Start Teleport'; ['d_teleport',[[vehicle player],_pos]] call XNetCallEvent; closedialog 0;";
onMapSingleClick "hint 'Start Teleport'; onMapSingleClick ''; closedialog 0; ['d_teleport',[[vehicle player],_pos]] call XNetCallEvent; true;";

d_a_d_p_kicked = nil;
while {alive player && dialog} do {
	if (!isNil "d_a_d_p_kicked") then {
		d_a_d_p_kicked = nil;
		lbClear _ctrl;
		_units = if (isMultiplayer) then {playableUnits} else {switchableUnits};
		{
			if (!isNull _x) then {
				_index = _ctrl lbAdd (name _x);
				_ctrl lbSetData [_index, str(_x)];
			};
		} forEach _units;
		_ctrl lbSetCurSel 0;
	};
	sleep 0.2;
};
onMapSingleClick "";
sleep 5;
d_phd_invulnerable = false;
sleep 0.5;
deleteMarkerLocal "d_admin_marker";